

library(haven)
library(labelled)
library(tidyverse)
library(psych)
library(estimatr)
library(margins)
library(ggridges)
library(emmeans)
library(stargazer)
library(logr)
library(sjmisc)


setwd("") #set your working directory
s<-read_sav("s.sav") #reading data; it should be in your working directory
v<-lookfor(s,"")

################################################################################################
################################################################################################
###################################### RECODING VARIABLES ######################################
################################################################################################
################################################################################################


################ ################  Experimental conditions  ################ ################ ################
################ ################ ################ ################ ################ ################ ################

s$cond[s$FL_117_DO_control==1|s$FL_119_DO_control==1|s$FL_134_DO_control==1|s$FL_139_DO_control==1|s$FL_144_DO_control==1|s$FL_149_DO_control==1|s$FL_129_DO_control==1|s$FL_124_DO_control==1]<-0
s$cond[s$FL_117_DO_consensus==1|s$FL_119_DO_consensus==1|s$FL_134_DO_consensus==1|s$FL_139_DO_consensus==1|s$FL_144_DO_consensus==1|s$FL_149_DO_consensus==1|s$FL_129_DO_consensus==1|s$FL_124_DO_consensus==1]<-1
s$cond[s$FL_117_DO_causal==1|s$FL_119_DO_causal==1|s$FL_134_DO_causal==1|s$FL_139_DO_causal==1|s$FL_144_DO_causal==1|s$FL_149_DO_causal==1|s$FL_129_DO_causal==1|s$FL_124_DO_causal==1]<-2
# conditions into three groups (0 = control; 1 = consensus; 2 = causal)
s$cond<-factor(s$cond) # conditions into factor
s$c<-fct_relevel(s$cond, "1") # alternative condition variable with reference category = consensus. This variable is used to test the difference between causal vs consensus.


################## Measured variables ################ ################
################ ################ ################ ################

################ pre-treatment  ################

s$base<-case_when(s$q8==1~6, ### baseline anthropocentric climate change belief 0-1
                  s$q8==2~5,
                  s$q9==1~0,
                  s$q9==2~1,
                  s$q10==1~4,
                  s$q10==2~2,
                  s$q10==3|s$q10==4~3)/6 

s$pid<-(s$q5-1)/6 # pid 0 (strong rep) - 1 (strong dem)
table(s$pid) # frequency 
s$dem<-case_when(s$q5<4~0,s$q5>4~1) # pid binary
s$biden<-(5-s$q3)/4 # biden support
s$trump<-(5-s$q4)/4 # trump support
s$trust0<- (4-s$q11)/3 #baseline trust in scientist 
s$crt<-((s$q18==4)+(s$q19==10)+(s$q20==39)+(s$q21==8)+(s$q22==6))/5 #crt

### Demographics ##

s$ba<-1*(s$q14>=5) # BA or higher education
s$female<-s$q12-1 
s$age<-s$q13
s%>%select(ba,female,age)%>%summary()

################ post-treatment  ################ 

### Main outcome
s$belief1<-case_when(s$q32==1~6,
                  s$q32==2~5,
                  s$q33==1~0,
                  s$q33==2~1,
                  s$q34==1~4,
                  s$q34==2~2,
                  s$q34==3|s$q34==4~3)/6 #post-treatment anthropocentric climate change belief item1

s$belief2<-(4-s$q36)/3 #post-treatment anthropocentric climate change belief item2
s$belief3<-(s$q37-1)/3 #post-treatment anthropocentric climate change belief item3
s$belief4<-(4-s$q38)/3 #post-treatment anthropocentric climate change belief item4
s$belief5<-(s$q39-1)/3 #post-treatment anthropocentric climate change belief item5
alpha(s%>%dplyr::select(belief1:belief5)) #reliability among 5 items (alpha = 0.86)
s$belief<-rowMeans(s%>%dplyr::select(belief1:belief5)) # cc belief index; this is the main outcome variable 
s$belief.b<-s$belief1>.5 ## binary outcome variable using item 1

### other outcomes 
s$consensus <-s$q41_7/100 #perceived consensus
s$trust1<- (4-s$q40)/3 # post-treatment trust
s$domore<-(5-s$q42)/4 # policy item1: should do more
s$green<-(12-s$q43)/6 # policy item2: green new deal
s$paris<-(10-s$q44)/6 # pol item3: paris agreement 
s$priority<-(4-s$q45)/3 # policy item4: priority
alpha(s%>%dplyr::select(domore:priority)) #reliability among 5 items (alpha = 0.94)
s$policy<-s%>%dplyr::select(domore:priority)%>%rowMeans() # polixy index

### shirkers


s<-s%>%mutate(
  shirk = case_when(
    is.na(q24_1)&is.na(q24_2)&is.na(q24_3)&is.na(q24_4)&is.na(q24_5)&is.na(q24_6)&is.na(q24_7)&is.na(q24_8)&is.na(q24_9)&
      is.na(q24_11)&is.na(q24_12)&is.na(q24_13)&is.na(q24_14)&is.na(q24_15)&is.na(q24_17)&
      q24_10==1 & q24_16 == 1 & q24_18 == 1
    ~ 0
  ),
  shirk = case_when(
    shirk == 0 ~ 0,
    is.na(shirk) ~ 1
  ),
  shirk2 = case_when(
    is.na(q24_1)&is.na(q24_2)&is.na(q24_3)&is.na(q24_4)&is.na(q24_5)&is.na(q24_6)&is.na(q24_7)&is.na(q24_8)&is.na(q24_9)&
      is.na(q24_11)&is.na(q24_12)&is.na(q24_13)&is.na(q24_14)&is.na(q24_15)&is.na(q24_17)&
      q24_10==1 & q24_16 == 1
    ~ 0
  ),
  shirk2 = case_when(
    shirk2 == 0 ~ 0,
    is.na(shirk2) ~ 1
  )
)

s$mins <- s$Duration__in_seconds_/60

#### manipulation check 


s$q48

s<-s%>%
  mutate(
    mcheck.consensus = ifelse(q48==1, 1, 0),
    mcheck.causal = ifelse(q48==2, 1, 0)
)






################################################################################################
################################################################################################
###################################### MAIN TEXT RESULTS #######################################
################################################################################################
################################################################################################


####################### FIGURE1 (Average Treatment Effect) ####################### 
############################################################################################


th<-theme(panel.grid.major=element_blank(),
          panel.grid.minor=element_blank(),
          panel.border=element_rect(colour="black"),
          axis.title.x=element_blank(),
          legend.position = c(0.3, 0.85),
          legend.text=element_text(size=7),
          legend.key.size = unit(2, 'mm'),
          plot.title = element_text(size=8, hjust=0.5),
          axis.title.y= element_text(size=8),
          axis.text.x = element_text(color = "black", size=8),
          axis.text.y = element_text(color = "black", size=7) ## common theme in following ggplots
)



#### running regression models and storing estimates in a dataframe called "est"
est<-rbind( 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s)%>%tidy(), # treatments vs control on belief index
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s)%>%tidy(), # causal vs. consensus on belief index (consensus is reference)
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s)%>%tidy(), # treatments vs control on binary belief  
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s)%>%tidy())%>% # causal vs. consensus on binary belief (consensus is reference)
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = rep(0:2,2)) 

### Figure 1A (left panel)

ggplot(data=est[1:3,], aes(x=as.numeric(cond), y=estimate, 
))+ 
  geom_point(aes(),size=6,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(label = est$lab[1:3], color = "white", size = 2)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(A) Belief in Anthropogenic Climate Change (Index)",x="", y = "Difference-in-Means by Conditions")+
  scale_x_continuous(breaks=c(0,1,2), limits = c(-0.2,2.2),
                     labels=c("Consensus\nvs. Control", "Causal\nvs. Control", "Causal\nvs. Consensus"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.02,.15)+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("h1a.png",width=3,height=3.8, dpi = 1200) 

### Figure 1B (right panel)

ggplot(data=est[4:6,], aes(x=as.numeric(cond), y=estimate, 
))+ 
  geom_point(aes(),size=6,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(label = est$lab[4:6], color = "white", size = 2)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(B) Belief in Anthropogenic Climate Change (Binary)",x="", y = "Difference-in-Means by Conditions")+
  scale_x_continuous(breaks=c(0,1,2), limits = c(-0.2,2.2),
                     labels=c("Consensus\nvs. Control", "Causal\nvs. Control", "Causal\nvs. Consensus"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.02,.15)+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("h1b.png",width=3,height=3.8, dpi = 1200)



####################### Figure 2 Heterogeneous Treatment Effect ####################### 
############################################################################################

th<-theme(panel.grid.major=element_blank(),
          panel.grid.minor=element_blank(),
          panel.border=element_rect(colour="black"),
          legend.position = c(0.3, 0.85),
          legend.text=element_text(size=7),
          legend.key.size = unit(2, 'mm'),
          plot.title = element_text(size=8, hjust=0.5),
          axis.title.y= element_text(color = "black", size=8),
          axis.title.x= element_text(color = "black", size=8),
          axis.text.x = element_text(color = "black", size=6),
          axis.text.y = element_text(color = "black", size=7)) ## common theme in following ggplots


########### Figure 2A: Heterogeneous Treatment Effect by PID ######### 

#### running regression models and storing estimates in a dataframe called "est"

est<-rbind(
  lm_robust(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==0))%>%tidy(), # marginal effect among strong reps
  lm_robust(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==1))%>%tidy(), # marginal effect among mod reps
  lm_robust(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==2))%>%tidy(), #...
  lm_robust(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==3))%>%tidy(),
  lm_robust(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==4))%>%tidy(),
  lm_robust(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==5))%>%tidy(),
  lm_robust(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==6))%>%tidy())%>% # marginal effect among strong dems
  mutate(conf.low = estimate-1.96*std.error)%>%
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>%
  mutate(pid = c(0,0,1,1,2,2,3,3,4,4,5,5,6,6))

### ggplot to create figure using the est dataframe created above 
ggplot(data=est, aes(x=pid, y=estimate, color = term, fill = term, linetype = term, shape = term))+ 
  geom_point()+
  geom_line(aes(),size=0.3)+geom_ribbon(aes(ymin=conf.low, ymax=conf.high), alpha = 0.2, colour = NA)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(A) Effects by Partisanship",x="Partisanship", y = "Difference-in-Means (vs. Control)")+
  scale_x_continuous(breaks=0:6, limits = c(-0.2,6.2),
                     labels=c("Strong\nRep","","", "Pure\nIndependent","","", "Strong\nDem"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+
  ylim(-.02,.17)+
  scale_shape_manual(name = c(""),
                     breaks=c("cond1","cond2"),
                     labels = c("Consensus","Causal"),
                     values=c(8,3))+
  scale_linetype_manual(name = c(""),
                        breaks=c("cond1","cond2"),
                        labels = c("Consensus","Causal"),
                        values=c(1,2))+
  scale_fill_manual(name = c(""),
                    breaks=c("cond1","cond2"),
                    labels = c("Consensus","Causal"),
                    values=c("black","#E7B800"))+
  scale_color_manual(name = c(""),
                     breaks=c("cond1","cond2"),
                     labels = c("Consensus","Causal"),
                     values=c("black","#E7B800"))+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("h2a-pid-index.png",width=2.5,height=3, dpi = 1200)


########### Figure 2B: Heterogeneous Treatment Effect by baseline belief in CC ######### 

#### running regression models and storing estimates in a dataframe called "est"

est<-rbind(
  lm_robust(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==0))%>%tidy(),
  lm_robust(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==1))%>%tidy(),
  lm_robust(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==2))%>%tidy(),
  lm_robust(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==3))%>%tidy(),
  lm_robust(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==4))%>%tidy(),
  lm_robust(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==5))%>%tidy(),
  lm_robust(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==6))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>%
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>%
  mutate(pid = c(0,0,1,1,2,2,3,3,4,4,5,5,6,6))


### ggplot to create figure using the est dataframe created above 
ggplot(data=est, aes(x=pid, y=estimate, color = term, fill = term, linetype = term, shape = term))+ 
  geom_point()+
  geom_line(aes(),size=0.3)+geom_ribbon(aes(ymin=conf.low, ymax=conf.high), alpha = 0.2, colour = NA)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(B) Effects by Prior Belief",x="Prior Belief in Climate Change", y = "Difference-in-Means (vs. Control)")+
  scale_x_continuous(breaks=0:6, limits = c(-0.2,6.2),
                     labels=c("Natural\nCause","","", "Equally\nResponsible","","", "Human\nCause"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+
  ylim(-.02,.17)+
  scale_shape_manual(name = c(""),
                     breaks=c("cond1","cond2"),
                     labels = c("Consensus","Causal"),
                     values=c(8,3))+
  scale_linetype_manual(name = c(""),
                        breaks=c("cond1","cond2"),
                        labels = c("Consensus","Causal"),
                        values=c(1,2))+
  scale_fill_manual(name = c(""),
                    breaks=c("cond1","cond2"),
                    labels = c("Consensus","Causal"),
                    values=c("black","#E7B800"))+
  scale_color_manual(name = c(""),
                     breaks=c("cond1","cond2"),
                     labels = c("Consensus","Causal"),
                     values=c("black","#E7B800"))+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("h2a-base-index.png",width=2.5,height=3, dpi = 1200)


########### Figure 2C: Heterogeneous Treatment Effect by baseline trust ######### 

#### running regression models and storing estimates in a dataframe called "est"

est<-rbind(
  lm_robust(belief~(cond+pid+base+trump+biden),s%>%subset(trust0*3==0))%>%tidy(),
  lm_robust(belief~(cond+pid+base+trump+biden),s%>%subset(trust0*3==1))%>%tidy(),
  lm_robust(belief~(cond+pid+base+trump+biden),s%>%subset(trust0*3==2))%>%tidy(),
  lm_robust(belief~(cond+pid+base+trump+biden),s%>%subset(trust0*3==3))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>%
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>%
  mutate(pid = c(0,0,1,1,2,2,3,3))

### ggplot to create figure using the est dataframe created above 

ggplot(data=est, aes(x=pid, y=estimate, color = term, fill = term, linetype = term, shape = term))+ 
  geom_point()+
  geom_line(aes(),size=0.3)+geom_ribbon(aes(ymin=conf.low, ymax=conf.high), alpha = 0.2, colour = NA)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(C) Effects by Trust in Scientists",x="Trust in Climate Scientists", y = "Difference-in-Means (vs. Control)")+
  scale_x_continuous(breaks=0:3, limits = c(-0.2,3.2),
                     labels=c("Not \n at all","Not \n too much","some", "A lot"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+
  ylim(-.02,.17)+
  scale_shape_manual(name = c(""),
                     breaks=c("cond1","cond2"),
                     labels = c("Consensus","Causal"),
                     values=c(8,3))+
  scale_linetype_manual(name = c(""),
                        breaks=c("cond1","cond2"),
                        labels = c("Consensus","Causal"),
                        values=c(1,2))+
  scale_fill_manual(name = c(""),
                    breaks=c("cond1","cond2"),
                    labels = c("Consensus","Causal"),
                    values=c("black","#E7B800"))+
  scale_color_manual(name = c(""),
                     breaks=c("cond1","cond2"),
                     labels = c("Consensus","Causal"),
                     values=c("black","#E7B800"))+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("h2a-trust-index.png",width=2.5,height=3, dpi = 1200)



####################### Figure2 D to F: causal vs consensus comparison by priors ####################### 
############################################################################################

## running regression models and storing estimates in a dataframe called `est` 
  # this time using the `c` variable where the reference category is switched to consensus condition

est<-rbind(
  lm_robust(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==0))%>%tidy(), # marginal effects by PID (0 = strong Rep; 1 = Strong Dem)
  lm_robust(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==1))%>%tidy(),
  lm_robust(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==2))%>%tidy(),
  lm_robust(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==3))%>%tidy(),
  lm_robust(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==4))%>%tidy(),
  lm_robust(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==5))%>%tidy(),
  lm_robust(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==6))%>%tidy(),
  lm_robust(belief~(c+pid+trust0+trump+biden),s%>%subset(base*6==0))%>%tidy(), # marginal effects by baseline belief (0 = strong belief in natural; 1 = strong belief in human cause)
  lm_robust(belief~(c+pid+trust0+trump+biden),s%>%subset(base*6==1))%>%tidy(),
  lm_robust(belief~(c+pid+trust0+trump+biden),s%>%subset(base*6==2))%>%tidy(),
  lm_robust(belief~(c+pid+trust0+trump+biden),s%>%subset(base*6==3))%>%tidy(),
  lm_robust(belief~(c+pid+trust0+trump+biden),s%>%subset(base*6==4))%>%tidy(),
  lm_robust(belief~(c+pid+trust0+trump+biden),s%>%subset(base*6==5))%>%tidy(),
  lm_robust(belief~(c+pid+trust0+trump+biden),s%>%subset(base*6==6))%>%tidy(),
  lm_robust(belief~(c+base+pid+trump+biden),s%>%subset(trust0*3==0))%>%tidy(), # marginal effects by trust in scientists 
  lm_robust(belief~(c+base+pid+trump+biden),s%>%subset(trust0*3==1))%>%tidy(),
  lm_robust(belief~(c+base+pid+trump+biden),s%>%subset(trust0*3==2))%>%tidy(),
  lm_robust(belief~(c+base+pid+trump+biden),s%>%subset(trust0*3==3))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>%
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>%
  mutate(pid = c(0:6,0:6,0:3))

########### Figure 2D: causal vs. consensus by PID ######### 

ggplot(data=est[1:7,], aes(x=pid, y=estimate))+ 
  geom_point(color = "peachpuff4")+
  geom_line(aes(),size=0.3,color = "peachpuff4")+geom_ribbon(aes(ymin=conf.low, ymax=conf.high), alpha = 0.2, fill = "peachpuff4", colour = NA)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(D) Causal vs. Consensus by PID",x="Partisanship", y = "Difference-in-Means (Causal vs. Consensus)")+
  scale_x_continuous(breaks=0:6, limits = c(-0.2,6.2),
                     labels=c("Strong\nRep","","", "Pure\nIndependent","","", "Strong\nDem"))+
  ylim(-.11,.11)+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("h2b-pid-index-dd.png",width=2.5,height=3, dpi = 1200) # Figure 2D

########### Figure 2E: causal vs. consensus by baseline belief ######### 

ggplot(data=est[8:14,], aes(x=pid, y=estimate))+ 
  geom_point(color = "peachpuff4")+
  geom_line(aes(),size=0.3,color = "peachpuff4")+geom_ribbon(aes(ymin=conf.low, ymax=conf.high), alpha = 0.2, fill = "peachpuff4", colour = NA)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(E) Causal vs. Consensus by Belief",x="Prior Belief in Climate Change", y = "Difference-in-Means (Causal vs. Consensus)")+
  scale_x_continuous(breaks=0:6, limits = c(-0.2,6.2),
                     labels=c("Natural\nCause","","", "Equally\nResponsible","","", "Human\nCause"))+
  ylim(-.11,.11)+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("h2b-base-index-dd.png",width=2.5,height=3, dpi = 1200)


########### Figure 2F: causal vs. consensus by baseline trust ######### 


ggplot(data=est[15:18,], aes(x=pid, y=estimate))+ 
  geom_point(color = "peachpuff4")+
  geom_line(aes(),size=0.3,color = "peachpuff4")+geom_ribbon(aes(ymin=conf.low, ymax=conf.high), alpha = 0.2, fill = "peachpuff4", colour = NA)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(F) Causal vs. Consensus by Trust",x="Trust in Climate Scientists", y = "Difference-in-Means (Causal vs. Consensus)")+
  scale_x_continuous(breaks=0:3, limits = c(-0.2,3.2),
                     labels=c("Not \n at all","Not \n too much","some", "A lot"))+
  ylim(-.11,.11)+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("h2b-trust-index-dd.png",width=2.5,height=3, dpi = 1200)



################################################################################################
################################################################################################
###################################### APPENDIX RESULTS ########################################
################################################################################################
################################################################################################




####################### Table D1 ####################### 


## running regressions 
m1<-lm(belief~(cond+base+pid+trust0+trump+biden),s)
m2<-lm(belief.b~(cond+base+pid+trust0+trump+biden),s)
m3<-lm(belief1~(cond+base+pid+trust0+trump+biden),s)
m4<-lm(belief2~(cond+base+pid+trust0+trump+biden),s)
m5<-lm(belief3~(cond+base+pid+trust0+trump+biden),s)
m6<-lm(belief4~(cond+base+pid+trust0+trump+biden),s)
m7<-lm(belief5~(cond+base+pid+trust0+trump+biden),s)

## creating latex table
stargazer(m1,m2,m3,m4,m5,m6,m7,
          se=starprep(m1,m2,m3,m4,m5,m6,m7,se_type="HC2"),
          dep.var.labels = c("Index","Caused by human (Binary)","Caused by human (Continuous)", "Human activity contributes", "Natural patterns don't contribute",
                             "Evidence for human cause", "No evidence for natrual cause"),
          covariate.labels = c("Consensus", "Causal", "Baseline Belief", "Partisanship", "Trust", "Trump Support", "Biden Support"),
          star.cutoffs = c(.05, .01, .005),
          add.lines = list(c("","Index","Caused","Caused", "Human", "Natural", "Evidence", "No evidence"),
                           c("","","by human","by human", "activity", "don't", "for", "for"),
                           c("","","(Binary)","(Continuous)", "contributes", "contribute", "human", "natural")),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## repeaet the same models with different reference category by replacing `cond` with `c` 

m1<-lm(belief~(c+base+pid+trust0+trump+biden),s)
m2<-lm(belief.b~(c+base+pid+trust0+trump+biden),s)
m3<-lm(belief1~(c+base+pid+trust0+trump+biden),s)
m4<-lm(belief2~(c+base+pid+trust0+trump+biden),s)
m5<-lm(belief3~(c+base+pid+trust0+trump+biden),s)
m6<-lm(belief4~(c+base+pid+trust0+trump+biden),s)
m7<-lm(belief5~(c+base+pid+trust0+trump+biden),s)

## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document
stargazer(m1,m2,m3,m4,m5,m6,m7,
          se=starprep(m1,m2,m3,m4,m5,m6,m7,se_type="HC2"),
          keep = "c2",
          star.cutoffs = c(.05, .01, .005),
          covariate.labels = c("Causal vs. consensus"),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))



####################### Table D2 ####################### 

## running regressions 
h2.tab1<-lm(belief~cond+base+trust0+trump+biden,s%>%subset(pid*6==0))
h2.tab2<-lm(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==1))
h2.tab3<-lm(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==2))
h2.tab4<-lm(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==3))
h2.tab5<-lm(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==4))
h2.tab6<-lm(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==5))
h2.tab7<-lm(belief~(cond+base+trust0+trump+biden),s%>%subset(pid*6==6))

## creating latex table
stargazer(h2.tab1, h2.tab2, h2.tab3, h2.tab4, h2.tab5, h2.tab6, h2.tab7,
          se=starprep(h2.tab1, h2.tab2, h2.tab3, h2.tab4, h2.tab5, h2.tab6, h2.tab7, se_type ="HC2"),
          dep.var.labels = c("DV = Belief in Anthropogenic Climate Change (Index)"),
          covariate.labels = c("Consensus", "Causal", "Baseline Belief", "Trust", "Trump Support", "Biden Support"),
          star.cutoffs = c(.05, .01, .005),
          add.lines = list(c("","Strong","Moderate","Leaning","Pure", "Leaning", "Moderate", "Strong"),
                           c("","Rep","Rep","Rep","Indep", "Dem", "Dem", "Dem")),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## repeaet the same models with different reference category by replacing `cond` with `c` 
h2.tab1<-lm(belief~c+base+trust0+trump+biden,s%>%subset(pid*6==0))
h2.tab2<-lm(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==1))
h2.tab3<-lm(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==2))
h2.tab4<-lm(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==3))
h2.tab5<-lm(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==4))
h2.tab6<-lm(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==5))
h2.tab7<-lm(belief~(c+base+trust0+trump+biden),s%>%subset(pid*6==6))


## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document
stargazer(h2.tab1, h2.tab2, h2.tab3, h2.tab4, h2.tab5, h2.tab6, h2.tab7,
          se=starprep(h2.tab1, h2.tab2, h2.tab3, h2.tab4, h2.tab5, h2.tab6, h2.tab7, se_type ="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))


####################### Table D3 ####################### 

## running regressions 
h2b1<-lm(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==0))
h2b2<-lm(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==1))
h2b3<-lm(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==2))
h2b4<-lm(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==3))
h2b5<-lm(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==4))
h2b6<-lm(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==5))
h2b7<-lm(belief~(cond+pid+trust0+trump+biden),s%>%subset(base*6==6))


## creating latex table
stargazer(h2b1, h2b2, h2b3, h2b4, h2b5, h2b6, h2b7,
          se=starprep(h2b1, h2b2, h2b3, h2b4, h2b5, h2b6, h2b7, se_type ="HC2"),
          dep.var.labels = c("DV = Belief in Anthropogenic Climate Change (Index)"),
          covariate.labels = c("Consensus", "Causal", "Partisanship", "Trust", "Trump Support", "Biden Support"),
          star.cutoffs = c(.05, .01, .005),
          add.lines = list(c("","Strong","Moderate","Weak","Not", "Weak", "Moderate", "Strong"),
                           c("","belief in","belief in","belief in","sure", "belief in", "belief in", "belief in"),
                           c("","natural","natural","natural","", "human", "human", "human"),
                           c("","causes","causes","causes","", "causes", "causes", "causes")),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## repeaet the same models with different reference category by replacing `cond` with `c` 
h2b1<-lm(belief~(c+pid+base+trump+biden),s%>%subset(base*6==0))
h2b2<-lm(belief~(c+pid+base+trump+biden),s%>%subset(base*6==1))
h2b3<-lm(belief~(c+pid+base+trump+biden),s%>%subset(base*6==2))
h2b4<-lm(belief~(c+pid+base+trump+biden),s%>%subset(base*6==3))
h2b5<-lm(belief~(c+pid+base+trump+biden),s%>%subset(base*6==4))
h2b6<-lm(belief~(c+pid+base+trump+biden),s%>%subset(base*6==5))
h2b7<-lm(belief~(c+pid+base+trump+biden),s%>%subset(base*6==6))

## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document
stargazer(h2b1, h2b2, h2b3, h2b4, h2b5, h2b6, h2b7,
          se=starprep(h2b1, h2b2, h2b3, h2b4, h2b5, h2b6, h2b7, se_type ="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))


####################### Table D4 ####################### 

## running regressions 
h2c1<-lm(belief~(cond+pid+base+trump+biden),s%>%subset(trust0*3==0))
h2c2<-lm(belief~(cond+pid+base+trump+biden),s%>%subset(trust0*3==1))
h2c3<-lm(belief~(cond+pid+base+trump+biden),s%>%subset(trust0*3==2))
h2c4<-lm(belief~(cond+pid+base+trump+biden),s%>%subset(trust0*3==3))

## creating latex table
stargazer(h2c1, h2c2, h2c3, h2c4, 
          se=starprep(h2c1, h2c2, h2c3, h2c4, se_type ="HC2"),
          dep.var.labels = c("DV = Belief in Anthropogenic Climate Change (Index)"),
          covariate.labels = c("Consensus", "Causal", "Partisanship", "Base belief" ,"Trump support", "Biden support"),
          star.cutoffs = c(.05, .01, .005),
          add.lines = list(c("Trust in","Not","Not","Some","A lot"),
                           c("scientists","at all","too much","","")),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## repeaet the same models with different reference category by replacing `cond` with `c` 
h2c1<-lm(belief~(c+pid+base+trump+biden),s%>%subset(trust0*3==0))
h2c2<-lm(belief~(c+pid+base+trump+biden),s%>%subset(trust0*3==1))
h2c3<-lm(belief~(c+pid+base+trump+biden),s%>%subset(trust0*3==2))
h2c4<-lm(belief~(c+pid+base+trump+biden),s%>%subset(trust0*3==3))

## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document
stargazer(h2c1, h2c2, h2c3, h2c4, 
          se=starprep(h2c1, h2c2, h2c3, h2c4, se_type ="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))




####################### Table D5 ####################### 

## running regressions 
m1<-lm(belief~cond*pid+(base+trust0+trump+biden)*pid,s) 
m2<-lm(belief~cond*base+(pid+trust0+trump+biden)*base,s) 
m3<-lm(belief~cond*trust0+(pid+base+trump+biden)*trust0,s) 

## creating latex table
## one should manually delete the lines with empty variable names and their standard error lines
## the omitted lines are interactions with control variables and moderators
stargazer(m1,m2,m3, 
          se=starprep(m1, se_type="HC2"),
          covariate.labels = c("Consensus", "Causal", "PID", "Baseline Belief", "Trust", "Trump Support", "Biden Support" , 
                               "Consensus $\\times$ PID", "Causal $\\times$ PID",
                               "","","","",
                               "Consensus $\\times$ Baseline Belief", "Causal $\\times$ Baseline Belief",
                               "","","","",
                               "Consensus $\\times$ Trust", "Causal $\\times$ Trust",
                               "","","",""),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## repeaet the same models with different reference category by replacing `cond` with `c` 
m1<-lm(belief~c*pid+(base+trust0+trump+biden)*pid,s) 
m2<-lm(belief~c*base+(pid+trust0+trump+biden)*base,s) 
m3<-lm(belief~c*trust0+(pid+base+trump+biden)*trust0,s) 

## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document
stargazer(m1,m2,m3, 
          se=starprep(m1, se_type="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus", 
                               "Causal vs. consensus $\\times$ PID",
                               "Causal vs. consensus $\\times$ Baseline belief", 
                               "Causal vs. consensus $\\times$ Trust in scientists"
          ),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))






####################### Table D6 ####################### 

## running regressions
m0<-lm(consensus~cond+base+pid+trust0+trump+biden,s)
m1<-lm(policy~cond+base+pid+trust0+trump+biden,s)
m2<-lm(domore~cond+base+pid+trust0+trump+biden,s)
m3<-lm(green~cond+base+pid+trust0+trump+biden,s)
m4<-lm(paris~cond+base+pid+trust0+trump+biden,s)
m5<-lm(priority~cond+base+pid+trust0+trump+biden,s)
m6<-lm(trust1~cond+base+pid+trust0+trump+biden,s)

## creating latex table
stargazer(m0, m1,m2,m3,m4,m5,m6,
          se=starprep(m0, m1,m2,m3,m4,m5,m6, se_type="HC2"),
          covariate.labels = c("Consensus", "Causal", "Baseline Belief", "Partisanship", "Trust", "Trump Support", "Biden Support"),
          star.cutoffs = c(.05, .01, .005),
          add.lines = list(c("","Perceived", "Policy","Policy 1","Policy 2", "Policy 3", "Policy 4", "Trust in"),
                           c("", "consensus", "index","Do more","New Deal", "Paris", "Priority", "scientists")),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## repeaet the same models with different reference category by replacing `cond` with `c` 
m0<-lm(consensus~c+base+pid+trust0+trump+biden,s)
m1<-lm(policy~c+base+pid+trust0+trump+biden,s)
m2<-lm(domore~c+base+pid+trust0+trump+biden,s)
m3<-lm(green~c+base+pid+trust0+trump+biden,s)
m4<-lm(paris~c+base+pid+trust0+trump+biden,s)
m5<-lm(priority~c+base+pid+trust0+trump+biden,s)
m6<-lm(trust1~c+base+pid+trust0+trump+biden,s)


## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document
stargazer(m0, m1,m2,m3,m4,m5,m6,
          se=starprep(m0, m1,m2,m3,m4,m5,m6, se_type="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))


####################### Table D7 ####################### 

m1<-lm(belief~cond*crt+(base+pid+trust0+trump+biden)*crt,s)

## creating latex table
## one should manually delete the lines for coefficients on CRT by control interactions
stargazer(m1,
          se=starprep(m1, se_type="HC2"),
          covariate.labels = c("Consensus", "Causal", "CRT", "Baseline Belief", "Partisanship", "Trust", "Trump Support", "Biden Support" , "Consensus $\\times$ CRT", "Causal $\\times$ CRT"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))


m1<-lm(belief~c*crt+(base+pid+trust0+trump+biden)*crt,s)


## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document
stargazer(m1,
          se=starprep(m1, se_type="HC2"),
          keep = c("c2", "c2:crt"),
          covariate.labels = c("Causal vs. consensus","Causal vs. consensus $\\times$ CRT"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))



####################### TABLE D8 ####################### 



## running regressions
m1<-lm(policy~cond+base+pid+trust0+trump+biden,s)
m2<-lm(domore~cond+base+pid+trust0+trump+biden,s)
m3<-lm(green~cond+base+pid+trust0+trump+biden,s)
m4<-lm(paris~cond+base+pid+trust0+trump+biden,s)
m5<-lm(priority~cond+base+pid+trust0+trump+biden,s)

## creating latex table
stargazer(m1,m2,m3,m4,m5,
          se=starprep(m1,m2,m3,m4,m5, se_type="HC2"),
          covariate.labels = c("Consensus", "Causal", "Baseline Belief", "Partisanship", "Trust", "Trump Support", "Biden Support"),
          star.cutoffs = c(.05, .01, .005),
          add.lines = list(c("", "Policy","Policy 1","Policy 2", "Policy 3", "Policy 4"),
                           c("", "index","Do more","New Deal", "Paris", "Priority")),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## repeaet the same models with different reference category by replacing `cond` with `c` 
m1<-lm(policy~c+base+pid+trust0+trump+biden,s)
m2<-lm(domore~c+base+pid+trust0+trump+biden,s)
m3<-lm(green~c+base+pid+trust0+trump+biden,s)
m4<-lm(paris~c+base+pid+trust0+trump+biden,s)
m5<-lm(priority~c+base+pid+trust0+trump+biden,s)


## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document
stargazer(m1,m2,m3,m4,m5,
          se=starprep(m1,m2,m3,m4,m5, se_type="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## p-values for the causal vs. consensus conditions

stargazer(m1,m2,m3,m4,m5,
          report=('vc*p'),
          se=starprep(m1,m2,m3,m4,m5, se_type="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))




####################### TABLE D9 ######################



## running regressions

m1<-lm(policy~cond+base+pid+trust0+trump+biden,s%>%filter(dem==1))
m2<-lm(domore~cond+base+pid+trust0+trump+biden,s%>%filter(dem==1))
m3<-lm(green~cond+base+pid+trust0+trump+biden,s%>%filter(dem==1))
m4<-lm(paris~cond+base+pid+trust0+trump+biden,s%>%filter(dem==1))
m5<-lm(priority~cond+base+pid+trust0+trump+biden,s%>%filter(dem==1))

## creating latex table

stargazer(m1,m2,m3,m4,m5,
          se=starprep(m1,m2,m3,m4,m5, se_type="HC2"),
          covariate.labels = c("Consensus", "Causal", "Baseline Belief", "Partisanship", "Trust", "Trump Support", "Biden Support"),
          star.cutoffs = c(.05, .01, .005),
          add.lines = list(c("", "Policy","Policy 1","Policy 2", "Policy 3", "Policy 4"),
                           c("", "index","Do more","New Deal", "Paris", "Priority")),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))


## repeaet the same models with different reference category by replacing `cond` with `c` 

m1<-lm(policy~c+base+pid+trust0+trump+biden,s%>%filter(dem==1))
m2<-lm(domore~c+base+pid+trust0+trump+biden,s%>%filter(dem==1))
m3<-lm(green~c+base+pid+trust0+trump+biden,s%>%filter(dem==1))
m4<-lm(paris~c+base+pid+trust0+trump+biden,s%>%filter(dem==1))
m5<-lm(priority~c+base+pid+trust0+trump+biden,s%>%filter(dem==1))

## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document

stargazer(m1,m2,m3,m4,m5,
          se=starprep(m1,m2,m3,m4,m5, se_type="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))



####################### TABLE D10 ####################### 

## running regressions


m1<-lm(policy~cond+base+pid+trust0+trump+biden,s%>%filter(dem==0))
m2<-lm(domore~cond+base+pid+trust0+trump+biden,s%>%filter(dem==0))
m3<-lm(green~cond+base+pid+trust0+trump+biden,s%>%filter(dem==0))
m4<-lm(paris~cond+base+pid+trust0+trump+biden,s%>%filter(dem==0))
m5<-lm(priority~cond+base+pid+trust0+trump+biden,s%>%filter(dem==0))

stargazer(m1,m2,m3,m4,m5,
          se=starprep(m1,m2,m3,m4,m5, se_type="HC2"),
          covariate.labels = c("Consensus", "Causal", "Baseline Belief", "Partisanship", "Trust", "Trump Support", "Biden Support"),
          star.cutoffs = c(.05, .01, .005),
          add.lines = list(c("", "Policy","Policy 1","Policy 2", "Policy 3", "Policy 4"),
                           c("", "index","Do more","New Deal", "Paris", "Priority")),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))

## repeaet the same models with different reference category by replacing `cond` with `c` 

m1<-lm(policy~c+base+pid+trust0+trump+biden,s%>%filter(dem==0))
m2<-lm(domore~c+base+pid+trust0+trump+biden,s%>%filter(dem==0))
m3<-lm(green~c+base+pid+trust0+trump+biden,s%>%filter(dem==0))
m4<-lm(paris~c+base+pid+trust0+trump+biden,s%>%filter(dem==0))
m5<-lm(priority~c+base+pid+trust0+trump+biden,s%>%filter(dem==0))

## creating latex table for just the coefficient on causal vs consensus
## one should manually insert the point estimate/SE lines from this second stargazer output to the previous latex table output in the latex document

stargazer(m1,m2,m3,m4,m5,
          se=starprep(m1,m2,m3,m4,m5, se_type="HC2"),
          keep = "c2",
          covariate.labels = c("Causal vs. consensus"),
          star.cutoffs = c(.05, .01, .005),
          style = "ajps",
          digits= 3,keep.stat = c("n","adj.rsq"))











####################### Figure E1 ####################### 


th<-theme(panel.grid.major=element_blank(),
          panel.grid.minor=element_blank(),
          panel.border=element_rect(colour="black"),
          axis.title.x=element_blank(),
          legend.position = c(0.3, 0.85),
          legend.text=element_text(size=8),
          legend.background = element_blank(),
          plot.title = element_text(size=8, hjust=0.5),
          axis.title.y= element_text(size=8),
          axis.text.x = element_text(color = "black", size=8),
          axis.text.y = element_text(color = "black", size=7) ## common theme in following ggplots
)


table(s$cond, s$q48)%>%chisq.test()


s%>%
  mutate(
    pass  = if_else(
      (cond=="0"&q48==3)|(cond=="1"&q48==1)|(cond=="2"&q48==2),1,0
    ),
    pass = tidyr::replace_na(pass,0))%>%
  pull(pass)%>%mean()

# 90.3% passed manipulation check

props<-c(s%>%
  filter(cond=="0")%>%
  pull(q48)%>%
  table()%>%
  prop.table(),
  s%>%
    filter(cond=="1")%>%
    pull(q48)%>%
    table()%>%
    prop.table(),
  s%>%
    filter(cond=="2")%>%
    pull(q48)%>%
    table()%>%
    prop.table()
)

t<-"Which best describes the message you read?"
a<-"discussed cryptocurrency"
b<-"explained there is a 97% consensus among climate scientists"
c<-"explained why scientists have concluded that human activities are causing climate change"

  
mcheck<-data.frame(
  y = props,
  x = c(2,3,1,6,7,5,10,11,9),
  answer = c(b,c,a,b,c,a,b,c,a),
  cond = c(rep("Control",3),rep("Consensus",3),rep("causal",3))
)


ggplot(mcheck, aes(x=x, y=y, color = answer, fill = answer))+geom_bar(stat="identity")+
  scale_color_manual(values = c("grey80", "grey40", "grey15"))+
  scale_fill_manual(values = c("grey80", "grey40", "grey15"))+
  scale_x_continuous(breaks = c(2,6,10), labels = c("Control\nGroup","Consensus\nGroup","Causal\nGroup"))+
  scale_y_continuous(breaks = c(0,.25,.5,.75,1), limits = c(0, 1.4))+
  labs(
    y = "Proportions", fill = t, color = t
  )+theme_bw()+th+
  theme(legend.position = c(0.45, 0.85),
        legend.box.margin = margin(t = 0, r = 0, b = 0, l = 0, unit = "mm"),
        legend.key.size=unit(.5, "cm"),
        legend.title = element_text(size = 8))
ggsave("mcheck.png",width=6.5,height=3.8, dpi = 1200) 

####################### Figure E2 ####################### 


est3<-rbind(
  lm_robust(q41_7~1,s%>%subset(cond=="0"))%>%tidy(), 
  lm_robust(q41_7~1,s%>%subset(cond=="1"))%>%tidy(),
  lm_robust(q41_7~1,s%>%subset(cond=="2"))%>%tidy()
)%>%
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(1)%>%as.factor())%>%
  mutate(cond = 0:2) 


ggplot(data=est3, aes(x=as.numeric(cond), y=estimate, 
))+ 
  geom_point(aes(),size=7,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(label = est3$lab[1:3], color = "white", size = 2)+
  geom_hline(yintercept = 97, linetype="dashed",color = "red4")+
  theme_bw()+
  labs(title="Perceived Scientific Consensus",x="", y = "Means by Conditions")+
  scale_x_continuous(breaks=c(0,1,2), limits = c(-0.2,2.2),
                     labels=c("Control", "Consensus", "Causal"))+
  scale_y_continuous(breaks = c(75,80, 85, 90, 95, 97, 100), labels = c("75", "80", "85", "90", "95", "Correct 97", "100"), limits = c(75, 100))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+
  th+ theme(legend.position = c(0.7, 0.85))
ggsave("mcheck3.png",width=4,height=3.8, dpi = 1200) 




####################### Figure E3 ####################### 


items<-c(
"No evidence for natural patterns cobtributing to climate change",
"Much evidence for human activity contributing to climate change",
"Natural patterns don't contribute to climate change",
"Human activity contributes to climate change",
"Climate change caused by human activity, instead of natural causes")

rbind( 
  lm_robust(belief1~(c+base+pid+trust0+trump+biden),s)%>%tidy(),  
  lm_robust(belief2~(c+base+pid+trust0+trump+biden),s)%>%tidy(),  
  lm_robust(belief3~(c+base+pid+trust0+trump+biden),s)%>%tidy(),  
  lm_robust(belief4~(c+base+pid+trust0+trump+biden),s)%>%tidy(),  
  lm_robust(belief5~(c+base+pid+trust0+trump+biden),s)%>%tidy())%>%  
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  filter(term == "c2")%>%
  mutate(lab = estimate%>%round(2)%>%format(nsmall=2)%>%as.factor(),
         x = 5:1)%>%
  ggplot(data=., aes(x=x, y=estimate, label = lab))+ 
  geom_point(aes(),size=7,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(color = "white", size = 2)+
  labs(y = "Differece-in-Means (Causal vs. Consensus)", x = "Survey Items")+
  scale_x_continuous(breaks = 1:5, labels = items)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+coord_flip()+
  theme_bw()+
  theme(panel.grid.major=element_blank(),
                   panel.grid.minor=element_blank(),
                   panel.border=element_rect(colour="black"),
                   axis.title.x=element_text(size=7),
                   axis.title.y= element_text(size=7),
                   axis.text.x = element_text(color = "black", size=7),
                   axis.text.y = element_text(color = "black", size=7))
ggsave("mcheck4.png",width=6.4,height=3, dpi = 1200) 


####################### Figure E4 ####################### 



th<-theme(panel.grid.major=element_blank(),
          panel.grid.minor=element_blank(),
          panel.border=element_rect(colour="black"),
          axis.title.x=element_blank(),
          legend.position = c(0.3, 0.85),
          legend.text=element_text(size=7),
          legend.key.size = unit(2, 'mm'),
          legend.background = element_blank(),
          plot.title = element_text(size=8, hjust=0.5),
          axis.title.y= element_text(size=8),
          axis.text.x = element_text(color = "black", size=8),
          axis.text.y = element_text(color = "black", size=7) ## common theme in following ggplots
)



est<-rbind( 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(), # treatments vs control on belief index
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(), # causal vs. consensus on belief index (consensus is reference)
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==1))%>%tidy(), # treatments vs control on binary belief  
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s%>%filter(shirk==1))%>%tidy())%>% # causal vs. consensus on binary belief (consensus is reference)
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = rep(0:2,2),
         sample = c("Non-Shirkers","Non-Shirkers","Non-Shirkers","Shirkers","Shirkers","Shirkers")) 


lm_robust(belief.b~(cond+base+pid+trust0+trump+biden)*shirk,s)%>%tidy()

ggplot(data=est, aes(x=as.numeric(cond), y=estimate, shape = sample, label = lab
))+ 
  geom_point(aes(),size=6,alpha=1, position=position_dodge(width=0.4))+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high), position=position_dodge(width=0.4))+
  geom_text( size = 2, position=position_dodge(width=0.4), color = "white")+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  scale_shape_manual(values = c(19,15))+
  theme_bw()+
  labs(title="(A) Belief in Anthropogenic Climate Change (Index)",x="", y = "Difference-in-Means by Conditions")+
  scale_x_continuous(breaks=c(0,1,2), limits = c(-0.2,2.2),
                     labels=c("Consensus\nvs. Control", "Causal\nvs. Control", "Causal\nvs. Consensus"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.05,.15)+
  th+ theme(legend.position = c(0.25, 0.85))
ggsave("shirk_a.png",width=3,height=3, dpi = 1200) 


est<-rbind( 
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(), # treatments vs control on belief index
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(), # causal vs. consensus on belief index (consensus is reference)
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==1))%>%tidy(), # treatments vs control on binary belief  
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s%>%filter(shirk==1))%>%tidy())%>% # causal vs. consensus on binary belief (consensus is reference)
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%format(nsmall=2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = rep(0:2,2),
         sample = c("Non-Shirkers","Non-Shirkers","Non-Shirkers","Shirkers","Shirkers","Shirkers")) 


ggplot(data=est, aes(x=as.numeric(cond), y=estimate, shape = sample, label = lab
))+ 
  geom_point(aes(),size=6,alpha=1, position=position_dodge(width=0.4))+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high), position=position_dodge(width=0.4))+
  geom_text( size = 2, position=position_dodge(width=0.4), color = "white")+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  scale_shape_manual(values = c(19,15))+
  theme_bw()+
  labs(title="(B) Belief in Anthropogenic Climate Change (Binary)",x="", y = "Difference-in-Means by Conditions")+
  scale_x_continuous(breaks=c(0,1,2), limits = c(-0.2,2.2),
                     labels=c("Consensus\nvs. Control", "Causal\nvs. Control", "Causal\nvs. Consensus"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.05,.15)+
  th+ theme(legend.position = c(0.25, 0.15))
ggsave("shirk_b.png",width=3,height=3, dpi = 1200) 


####################### Figure E5 ####################### 


s$mins2<-ifelse(s$mins<30, s$mins, 30)
s$mins3<-ifelse(s$mins<20, s$mins, 20)

ggplot(data = s, aes(x= mins3))+geom_histogram(position = "stack", closed = "left", bins = 20, aes(y = after_stat(count / sum(count))))+
  scale_x_continuous(breaks =  c(0,1,2,3,4,5,10,15,20), labels = c("0","1","2","3","4",
    "5","10","15", "20+"
  ))+
  scale_y_continuous(labels = scales::percent)+
  geom_vline(xintercept = 5, linetype = "dashed", color = "red4")+
  theme_bw()+th+labs(x = "Completion Time (Minutes)", y = "")+
  theme(axis.title.x=element_text(size=8))
ggsave("time.png",width=5,height=2.5, dpi = 1200) 

frq(s$mins)
summary(s$mins)



####################### Figure E6 ####################### 

est<-rbind( 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), # treatments vs control on belief index
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), # causal vs. consensus on belief index (consensus is reference)
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(mins<5))%>%tidy(), # treatments vs control on binary belief  
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s%>%filter(mins<5))%>%tidy())%>% # causal vs. consensus on binary belief (consensus is reference)
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = rep(0:2,2),
         sample = c("5 mins or more","5 mins or more","5 mins or more","Less than 5 mins","Less than 5 mins","Less than 5 mins")) 


ggplot(data=est, aes(x=as.numeric(cond), y=estimate, shape = sample, label = lab
))+ 
  geom_point(aes(),size=6,alpha=1, position=position_dodge(width=0.4))+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high), position=position_dodge(width=0.4))+
  geom_text( size = 2, position=position_dodge(width=0.4), color = "white")+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  scale_shape_manual(values = c(19,15))+
  theme_bw()+
  labs(title="(A) Belief in Anthropogenic Climate Change (Index)",x="", y = "Difference-in-Means by Conditions")+
  scale_x_continuous(breaks=c(0,1,2), limits = c(-0.2,2.2),
                     labels=c("Consensus\nvs. Control", "Causal\nvs. Control", "Causal\nvs. Consensus"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.05,.15)+
  th+ theme(legend.position = c(0.25, 0.85))
ggsave("shirk_c.png",width=3,height=3, dpi = 1200) 


est<-rbind( 
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), # treatments vs control on belief index
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), # causal vs. consensus on belief index (consensus is reference)
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(mins<5))%>%tidy(), # treatments vs control on binary belief  
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s%>%filter(mins<5))%>%tidy())%>% # causal vs. consensus on binary belief (consensus is reference)
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(2)%>%format(nsmall=2)%>%as.factor())%>%
  filter(term == "cond1"|term == "cond2"|term == "c2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = rep(0:2,2),
         sample = c("5 mins or more","5 mins or more","5 mins or more","Less than 5 mins","Less than 5 mins","Less than 5 mins")) 


ggplot(data=est, aes(x=as.numeric(cond), y=estimate, shape = sample, label = lab
))+ 
  geom_point(aes(),size=6,alpha=1, position=position_dodge(width=0.4))+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high), position=position_dodge(width=0.4))+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  geom_text( size = 2, position=position_dodge(width=0.4), color = "white")+
  scale_shape_manual(values = c(19,15))+
  theme_bw()+
  labs(title="(B) Belief in Anthropogenic Climate Change (Binary)",x="", y = "Difference-in-Means by Conditions")+
  scale_x_continuous(breaks=c(0,1,2), limits = c(-0.2,2.2),
                     labels=c("Consensus\nvs. Control", "Causal\nvs. Control", "Causal\nvs. Consensus"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.05,.15)+
  th+ theme(legend.position = c(0.25, 0.15))
ggsave("shirk_d.png",width=3,height=3, dpi = 1200) 


####################### Figure E7 ####################### 

rbind( 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s)%>%tidy(), 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(),
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0&mins>=5))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(3)%>%as.factor())%>%
  filter(term == "cond1")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = 1:4)%>%
  ggplot(data=., aes(x=as.numeric(cond), y=estimate, label = lab))+ 
  geom_point(aes(),size=7,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(color = "white", size = 2)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(A) Consensus Treat on Belief Index",x="", y = "Difference-in-Means (Consensus vs. Control)")+
  scale_x_continuous(breaks=c(1,2,3,4), limits = c(0.8,4.2),
                     labels=c("All", "Shirkers\nDropped", "Rushers\nDropped", "Shirkers &\nRushers\nDropped"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.002,.1)+
  th+ theme(plot.title = element_text(size=7, hjust  = .5),          
    axis.title.y= element_text(size=6),
                      axis.text.x = element_text(color = "black", size=6),
                      axis.text.y = element_text(color = "black", size=6))  
ggsave("dropping1.png",width=2.15,height=2.5, dpi = 1200) 



rbind( 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s)%>%tidy(), 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(),
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), 
  lm_robust(belief~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0&mins>=5))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(3)%>%as.factor())%>%
  filter(term == "cond2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = 1:4)%>%
  ggplot(data=., aes(x=as.numeric(cond), y=estimate, label = lab))+ 
  geom_point(aes(),size=7,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(color = "white", size = 2)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(B) Causal Treat on Belief Index",x="", y = "Difference-in-Means (Causal vs. Control)")+
  scale_x_continuous(breaks=c(1,2,3,4), limits = c(0.8,4.2),
                     labels=c("All", "Shirkers\nDropped", "Rushers\nDropped", "Shirkers &\nRushers\nDropped"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.002,.1)+
  th+ theme(plot.title = element_text(size=7, hjust  = .5),          
            axis.title.y= element_text(size=6),
            axis.text.x = element_text(color = "black", size=6),
            axis.text.y = element_text(color = "black", size=6))  
ggsave("dropping2.png",width=2.15,height=2.5, dpi = 1200) 




rbind( 
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s)%>%tidy(), 
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(),
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), 
  lm_robust(belief~(c+base+pid+trust0+trump+biden),s%>%filter(shirk==0&mins>=5))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(3)%>%as.factor())%>%
  filter(term == "c2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = 1:4)%>%
  ggplot(data=., aes(x=as.numeric(cond), y=estimate, label = lab))+ 
  geom_point(aes(),size=7,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(color = "white", size = 2)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(C) Diffence in Effects on Index",x="", y = "Difference-in-Means (Causal vs. Consensus)")+
  scale_x_continuous(breaks=c(1,2,3,4), limits = c(0.8,4.2),
                     labels=c("All", "Shirkers\nDropped", "Rushers\nDropped", "Shirkers &\nRushers\nDropped"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.002,.1)+
  th+ theme(plot.title = element_text(size=7, hjust  = .5),          
            axis.title.y= element_text(size=6),
            axis.text.x = element_text(color = "black", size=6),
            axis.text.y = element_text(color = "black", size=6))  
ggsave("dropping3.png",width=2.15,height=2.5, dpi = 1200) 





rbind( 
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s)%>%tidy(), 
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(),
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), 
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0&mins>=5))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(3)%>%as.factor())%>%
  filter(term == "cond1")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = 1:4)%>%
  ggplot(data=., aes(x=as.numeric(cond), y=estimate, label = lab))+ 
  geom_point(aes(),size=7,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(color = "white", size = 2)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(D) Consensus Treat on Binary Belief",x="", y = "Difference-in-Means (Consensus vs. Control)")+
  scale_x_continuous(breaks=c(1,2,3,4), limits = c(0.8,4.2),
                     labels=c("All", "Shirkers\nDropped", "Rushers\nDropped", "Shirkers &\nRushers\nDropped"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.02,.151)+
  th+ theme(plot.title = element_text(size=7, hjust  = .5),          
            axis.title.y= element_text(size=6),
            axis.text.x = element_text(color = "black", size=6),
            axis.text.y = element_text(color = "black", size=6))  
ggsave("dropping4.png",width=2.15,height=2.5, dpi = 1200) 



rbind( 
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s)%>%tidy(), 
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(),
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), 
  lm_robust(belief.b~(cond+base+pid+trust0+trump+biden),s%>%filter(shirk==0&mins>=5))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(3)%>%as.factor())%>%
  filter(term == "cond2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = 1:4)%>%
  ggplot(data=., aes(x=as.numeric(cond), y=estimate, label = lab))+ 
  geom_point(aes(),size=7,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(color = "white", size = 2)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(E) Causal Treat on Binary Belief",x="", y = "Difference-in-Means (Causal vs. Control)")+
  scale_x_continuous(breaks=c(1,2,3,4), limits = c(0.8,4.2),
                     labels=c("All", "Shirkers\nDropped", "Rushers\nDropped", "Shirkers &\nRushers\nDropped"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.02,.151)+
  th+ theme(plot.title = element_text(size=7, hjust  = .5),          
            axis.title.y= element_text(size=6),
            axis.text.x = element_text(color = "black", size=6),
            axis.text.y = element_text(color = "black", size=6))  
ggsave("dropping5.png",width=2.15,height=2.5, dpi = 1200) 




rbind( 
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s)%>%tidy(), 
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s%>%filter(shirk==0))%>%tidy(),
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s%>%filter(mins>=5))%>%tidy(), 
  lm_robust(belief.b~(c+base+pid+trust0+trump+biden),s%>%filter(shirk==0&mins>=5))%>%tidy())%>%
  mutate(conf.low = estimate-1.96*std.error)%>% 
  mutate(conf.high = estimate+1.96*std.error)%>%
  mutate(lab = estimate%>%round(3)%>%as.factor())%>%
  filter(term == "c2")%>% # keeping only mean differences across conditions from the regressions
  mutate(cond = 1:4)%>%
  ggplot(data=., aes(x=as.numeric(cond), y=estimate, label = lab))+ 
  geom_point(aes(),size=7,alpha=1)+ 
  geom_linerange(aes(ymin=conf.low, ymax=conf.high))+
  geom_text(color = "white", size = 2)+
  geom_hline(yintercept = 0, linetype="dashed",size=0.2)+
  theme_bw()+
  labs(title="(F) Diffence in Effects on Binary",x="", y = "Difference-in-Means (Causal vs. Consensus)")+
  scale_x_continuous(breaks=c(1,2,3,4), limits = c(0.8,4.2),
                     labels=c("All", "Shirkers\nDropped", "Rushers\nDropped", "Shirkers &\nRushers\nDropped"))+
  guides(fill=guide_legend(title=NULL),color=guide_legend(title=NULL),linetype=guide_legend(title=NULL),shape=guide_legend(title=NULL))+ylim(-.02,.151)+
  th+ theme(plot.title = element_text(size=7, hjust  = .5),          
            axis.title.y= element_text(size=6),
            axis.text.x = element_text(color = "black", size=6),
            axis.text.y = element_text(color = "black", size=6))  
ggsave("dropping6.png",width=2.15,height=2.5, dpi = 1200) 







